<#assign path = request.getContextPath() />
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>创建班次</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="stylesheet" href="${path}/static/css/font.css">
		<link rel="stylesheet" href="${path}/static/css/css.css">
		<link rel="stylesheet" type="text/css" href="${path}/static/css/xadmin.css"/>
		<script type="text/javascript" src="${path}/static/lib/layui/layui.js"></script>
		<script type="text/javascript" src="${path}/static/js/xadmin.js"></script>
	</head>
	<body>
		<div class="wapper">
			<ul class="set-lists">
				<li class="set-list">
					<label class="form-label">班次名称</label>
					<input type="text" id="name" name="name" class="set-input">
				</li>
				<li class="set-list">
					<label class="form-label">是否跨天</label>
					<select  class="set-input" id="overDay">
						<option value="1">跨天</option>
						<option value="2">当天</option>
					</select>
				</li>
				<li class="set-list">
					<label class="form-label">导入成员</label>
					<input type="file" style="display: none"
                           onchange="importFile(event)"/>
					<button class="upload" onclick="importSchedule(this)">导入</button>
				</li>
				<li class="set-list">
					<label class="layui-form-label"></label>
					<button class="btn"  onclick="creatSchedul()">保存</button>
					<button class=" btn-nobg" lay-filter="reset" lay-submit="reset">重置</button>
				</li>
			</ul>
		</div>
	</body>

	<script>
		var formData = new FormData();
		function importFile(event) {
			formData.append("file", event.target.files[0]);
        };

        function importSchedule(obj) {
            $(obj).siblings('input').trigger('click');
		};

		function creatSchedul() {
			var name = $('#name').val();
			var overDay = $('#overDay').val();
            formData.append("name", name);
            formData.append("type", overDay);
            $.ajax({
                url:'/api/employee/schedul/create',
                type:'POST',
                data:formData,
                processData : false, // 使数据不做处理
                contentType : false,
                success: function (res) {
                    console.log(res);
                    if (res.status == 200) {
                        layer.msg("上传成功",{
                            icon:6
                        },function () {
                            //关闭当前frame
                            xadmin.close();
                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                    }
                }
            });
        };

	</script>
</html>
